using System;
using System.Windows.Forms;
using SqlRunner;
using SQLRunnerLib.Util;
using SQLRunnerLib.Exceptions;
using SQLRunnerLib.Services;
using SQLServices.Log;

namespace SqlRunner
{
	/// <summary>
	/// Entry point for the SQL Server Runnner application
	/// </summary>
	public class MainClass
	{
		private MainClass(){}
		[STAThread]
		static void Main(string[] args) 
		{
			FormMainController controller = new FormMainController();
			if (args.Length > 0) 
			{
                try
                {
				    LineParser _parser = new LineParser(args);
				    if (_parser.IsProjectAvailable)
				    {
					    controller.Project = _parser.Project;
					    controller.RefreshProject();
				    }
                }
                catch (ValidationException ex)
                {
                    ServiceContainer.Instance.Logger.LogMessage(ex.Message, MsgLevel.Error);
                }
			}
			Application.Run(controller.FormInstance);
		}
	}
}
